//
//  InputSecretVC.m
//  9Top
//
//  Created by KorzJ on 2016/12/8.
//  Copyright © 2016年 KorzJ. All rights reserved.
//

#import "InputSecretVC.h"
#import "JPassField.h"

#define K_Field_Height 45  //每一个输入框的高度

@interface InputSecretVC ()<UITextFieldDelegate,JinputcompleteDelegate>
{
//    UITextField *_tf;
    NSString *_password;
}
@property (weak, nonatomic) IBOutlet UIView *secrectView;
@property(nonatomic)JPassField *JPassField;
@property (weak, nonatomic) IBOutlet UIView *extraBgView;
@property (nonatomic,strong) InputSecretVC *inputSecretVc;
@end

@implementation InputSecretVC

#pragma mark -
#pragma mark LIFE CYCLE

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    _extraBgView.hidden = YES;
    [self layoutConfig];
    [self layoutInputSecret];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];

}

#pragma mark -
#pragma mark LAYOUT

- (void)layoutConfig{
    self.view.backgroundColor = [UIColor clearColor];

    
}

- (void)layoutInputSecret{    
    self.JPassField = [[JPassField alloc] initWithFrame:CGRectMake(0, 0, K_SCREEN_WIDTH - 32, K_Field_Height)];
    __weak InputSecretVC *weakSelf = self;
    _JPassField.block = ^(NSString *str) {
            _password = str;
            [weakSelf performSelector:@selector(confirm:) withObject:nil afterDelay:0];
    };
    self.JPassField.delegate = self;
    [self.inputBg addSubview:self.JPassField];
    
}

- (void)inputcomplete:(UITextField *)textField
{
//    _password = textField.text;
}

#pragma mark -
#pragma mark EVENT

- (IBAction)cancel:(UIButton *)sender {
    [self.view removeFromSuperview];
}

- (IBAction)confirm:(UIButton *)sender {
    if (self.block) {
        self.block(_password);
        [self.view removeFromSuperview];
    };
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
